#ifndef FILE_HANDLE_H_
#define FILE_HANDLE_H_

#include "./../write_read_module/buffer.h"

#include <cstdint>
#include <memory>
#include <string>

class FileOperate;
class Description;
class FileHandle
{
public:
    explicit FileHandle(const std::string & filename);
    explicit FileHandle(const std::string & filename, int buffer_size);
    int       OpenFileOnlyRead();
    int       OpenFileReadWrite();
    int       OpenFileAppendWrite();
    uint8_t * Data(int & length);
    int       Write(const uint8_t * data, int length) const;
    int       Write(WriteBuffer & buffer) const;
    void      RemoveDataLength(int length);
    uint64_t  GetFileSize() const;
    int       DeleteFile() const;
private:
    std::string m_file_name;

    WriteReadBuffer              m_read_buffer;
    std::shared_ptr<Description> m_description;
    std::shared_ptr<FileOperate> m_file_operate;
};

class FileHandleUtil
{
public:
    static int MakeDir(const std::string & dir_path);
};

#endif
